package com.cu.shardingjdbcmybaties.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cu.shardingjdbcmybaties.entity.User;
import com.cu.shardingjdbcmybaties.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("add")
    public boolean add(@RequestBody User user) {
        userService.addUser(user);
        return true;
    }

    @GetMapping("query")
    public User queryByName(String name) {
        return userService.queryByName(name);
    }


    @GetMapping("queryAll")
    public List<User> queryAll(){
        return userService.queryAll();
    }
}
